const express = require( 'express' );

// 创建实例
const app = new express();


// app.use( ( req, res ) => {
//   res.json({
//     code: 200,
//     message: 'success',
//     data: {
//       list: [{
//         name: 'alibaba',
//         age: '12'
//       }],
//       total: 1000
//     }
//   })
// });

app.get('/name/:age', (req, res) => {
  let { age } = req.params;
  res.json({
    name: 'Tom',
    age
  });
});

app.post('/name', (req, res) => {
  // console.log(req);
  // console.log( res, 'res' );

  res.end(JSON.stringify({ name: 'alibaba' }) );
})

app.listen(3000, () => {
  console.log( 'Server Start Successful 127.0.0.1:3000' );
});